//Javascript reading notes:
//OBJECTS:
//to find the typeof object use typeof

typeof flight.number;// number

//can use delete to remove a variable from an object:
delete another_stooge.nickname;

//all objects come from the Object.prototype
//retrieving a property name from an object then looks up the change to its parent prototypes

//can use the hasOwnProperty to look if a property exists in an object but doesn't go up the prototype chain.
flight.hasOwnProperty('number');
//other approach to looking for properites is to 

//to avoid problems with global naming  conflicting with other libriaries can use:
MyApp.stooge= { "firstname" : "joe"};

//FUNCTIONS:
//functions are objects:
//Object.prototype -> Function.prototype = function
//as they are objects functions can be added to arrays, stored in variables and added to other objects.
//in addition to the function parameters a function gets passed the this and arguments.
//invocation of functions can be done using 4 different invocation patterns:
//method invocation pattern used when a function is part of an object:
var myObject= {
   value : 0,
increment : function ( inc ){
		this.value += typeof inc =='number' ? inc : 1;
		}
};
//use it:
myObject.increment();
document.writeln(myObject.value);
//the function invocation pattern
var sum = add(3, 4);
//this function is then bound to the global object can use the var that= this workaround
//so to augment myObject with a double method:
myObject.double = function () {
	var that = this;//workaround
	 var helper = function (){
		 that.value= add(that.value, that.value);
		 };
	helper();	//invoke helper as a function 
};
	//invoke double as a method
myObject.double();
document.writeln(myObject.value);




//There are no runtime errors when the number of arguments to 
